﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;
using SDLITS.Model;
using SDLITS.Common;

namespace EmptyProjectNet20
{
    public partial class hello : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }
        }
        private void BindGrid()
        {
            // 1.设置总项数（特别注意：数据库分页一定要设置总记录数RecordCount）
            Grid1.RecordCount = SDDbSession.Default.From<SDLITS.Model.Menu>().Count();

            // 2.获取当前分页数据
            List<SDLITS.Model.Menu> items = SDDbSession.Default.From<SDLITS.Model.Menu>().Page(Grid1.PageSize, (Grid1.PageIndex + 1)).ToList();

            // 3.绑定到Grid
            Grid1.DataSource = items;
            Grid1.DataBind();

        }

        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;
            BindGrid();
        }

    }
}
